
from wxSerialConfigDialog import *
import serial


class ConnectDialog(SerialConfigDialog):
    
    def __init__(self, *args, **kwds):
        SerialConfigDialog.__init__(self, *args, **kwds)
        self.button_ok.SetLabel("Connect")
        self.SetTitle("Connect")




class MyApp(wx.App):
    """Test code"""
    def OnInit(self):
        wx.InitAllImageHandlers()
        
        ser = serial.Serial()
        print ser
        #loop until cancel is pressed, old values are used as start for the next run
        #show the different views, one after the other
        #value are kept.
        for flags in (SHOW_BAUDRATE, SHOW_FLOW, SHOW_FORMAT, SHOW_TIMEOUT, SHOW_ALL):
            dialog_serial_cfg = ConnectDialog(None, -1, "", serial=ser, show=flags)
            self.SetTopWindow(dialog_serial_cfg)
            result = dialog_serial_cfg.ShowModal()
            print ser
            if result != wx.ID_OK:
                break
        #the user can play around with the values, CANCEL aborts the loop
        while 1:
            dialog_serial_cfg = ConnectDialog(None, -1, "", serial=ser)
            self.SetTopWindow(dialog_serial_cfg)
            result = dialog_serial_cfg.ShowModal()
            print ser
            if result != wx.ID_OK:
                break
        return 0

# end of class MyApp

if __name__ == "__main__":
    app = MyApp(0)
    app.MainLoop()